<?php

use think\facade\Route;

/** 接口 */
Route::group(function () {
    Route::get('list$', '@index');
    Route::get('search$', '@search');

    Route::group('<id>', function () {
        Route::get('$', '@info');
        Route::get('home$', '@home');
        Route::get('course$', '@course');
    })->pattern(['id' => '\d+']);
})
    ->middleware(['withoutLogin'])
    ->prefix('\app\school\service\school\School');


Route::group('auth', function () {
    Route::get('$', '@authFetch');
    Route::post('$', '@authSubmit')->middleware(['phoneCheck']);
})->prefix('\app\school\service\school\School');

/** 后台管理接口 */
Route::group('admin', function () {
    Route::get('list', '@index'); // 机构列表数据
    Route::get('create', '@create'); // 创建机构-页面
    Route::post('create', '@create'); // 创建机构-提交

    Route::group('<id>', function () {
        Route::get('edit', '@edit'); // 修改机构-页面
        Route::put('edit$', '@edit'); // 修改机构-提交
        Route::delete('$', '@delete'); // 删除机构-软删除
        Route::put('edit/<field>', '@editField');

    })->pattern(['id' => '\d+']);

    // 待审核机构
    Route::group('waiting', function () {
        Route::get('$', '@waiting'); // 列表
        Route::get('<id>/examine', '@examine'); // 审核界面
        Route::post('<id>/examine', '@examine'); // 审核界面
    });

    /** 搜索 */
    Route::get('search', '@search');
    /** 批量操作 */
    Route::put('disables', '@disables');// 批量禁用
    Route::put('enables', '@enables');// 批量启用
    Route::delete('deletes/<ids>', '@deletes')->pattern(['ids' => '[\d,]+']);// 批量删除
})->prefix('\app\school\service\school\admin\School')->middleware(['adminRoute']);
